package com.kfm.jdbc.day01;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo03 {

    public static void main(String[] args) {
        // 创建一个 kaifamiao 数据库，在数据库中创建一个 dept 表
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }

        String url = "jdbc:mysql://localhost:3306/company_info";
        String user = "root";
        String password = "root";

        try (Connection connection = DriverManager.getConnection(url, user, password);
        ) {

            // 修改 schema TODO( 目前不行 )
            connection.setSchema("kaifamiao");
            // 创建表
            String sql = "create table if not exists dept1 ( dept_no int auto_increment primary key, dept_name varchar(20) unique )";
            Statement statement = connection.prepareStatement(sql);

            statement.execute(sql);


        } catch (SQLException e) {
            throw new RuntimeException(e);
        }



    }



}
